function showUserLoginInterface(){
	jQ("#user_logininterface div.content div.otherlogin a.sina").unbind("click").bind("click",function (){
		var url=window.location.href;
		jQ.ajax({
			type: "POST",
			url: "userAjax!saveCurrentHref.action",
			data:{
				suffixurl:url
			},
			success:function(data){
				jQ.ajax({
					type: "POST",
					url: "createSinaOAuth2URL.action",
					data:{
						suffixurl:""
					},
					success:function(data){
						if(data.result){
							window.location.href=data.oauthurl;
						}else{
							alert(data.errormsg);
						}
					}
				});
			}
		});
	});
	jQ("#user_logininterface_wrap").fadeIn();
	
	jQ("#user_logininterface_errorinfo").text(" ");
	jQ("#userlogin_form").validate({
		rules:{   
			username:{   
		        required:true
		    },
		    password:{
		    	required:true
		    }
		},
		messages:{
			username: {  
				required: "请输入账号名称"
			},
			password: {  
				required: "请输入密码"
			}
		},
		errorPlacement: function(error,element)     // 将错误提示信息放在什么地方     
		{
			error.appendTo(jQ("#user_logininterface_errorinfo"));
		},
        submitHandler: function(form) {
        	jQ("#loadingui").show();
        	signIn();
        	return false;
        },
        focusInvalid: false,   
        onkeyup: false  
	});
	
	jQ("#user_logininterface_close").unbind("click").bind("click",function(){
		jQ("#user_logininterface_wrap").fadeOut();
	});
}

function signIn(){
	var username = jQ("#userlogin_username").val();
	var password = jQ("#userlogin_password").val();
	jQ.ajax({
		type: "POST",
		url: "userAjax!login.action",
		data:{
			emailInput : username,
			pwdInput : password
		},
		success:function(data){
			var dataObj=data;
			if(dataObj.result){
				var userstatus=dataObj.userstatus;
				if(userstatus==0){
					jQ("#ALERT").dialog({
						buttons:[{
							text : "确定",
							click: function() {
								resendActiveEmail();
							}
						},
						{
							text : "取消",
							click: function() {jQ(this).dialog("close");}
						}
						]
					});
					jQ("#ALERT p").empty().append("您的账号还未激活，是否需要再次发送激活邮件？");
					jQ("#ALERT").parent().css('font', "14px \"Trebuchet MS\", sans-serif");
					jQ("#ALERT").dialog('open');
				}else if(userstatus==2){
					jQ("#user_logininterface_errorinfo").text("您的账号被禁止登录");
				}else{
					
					window.location.href=jQ("#userlogin_form").data("loginurl");
				}
			}else{
				jQ("#user_logininterface_errorinfo").text(dataObj.errormsg);
			}
			jQ("#loadingui").hide();
		}
	});
}

function resendActiveEmail(){
	var username = jQ("#userlogin_username").val();
	var password = jQ("#userlogin_password").val();
	jQ("#ALERT").dialog({
		buttons:[{
			text : "确定",
			click: function() {
				jQ(this).dialog("close");
			}
			}
		]
	});
	jQ.ajax({
		type: "POST",
		url: "userAjax!resendActiveEmail.action",
		data:{
			emailInput : username,
			pwdInput : password
		},
		success:function(data){
			var dataObj=data;
			if(dataObj.result){
				jQ("#ALERT p").empty().append("激活邮件发送成功，请尽快登录邮箱激活。");
			}else{
				jQ("#ALERT p").empty().append(dataObj.errormsg);
			}
		}
	});
}